#include<bits/stdc++.h>
using namespace std;
int T;
int pos[100005],l[100005],r[100005],d[100005],v0[100005],a[100005];
pair<int,int>pp[100005];
void solve(){
    memset(l,0,sizeof l);
    memset(r,0,sizeof r);
    memset(pos,0,sizeof pos);
    int n,m,L,v;
    cin>>n>>m>>L>>v;
    for(int i=1;i<=n;i++){
        cin>>d[i]>>v0[i]>>a[i];
    }
    for(int i=1;i<=m;i++)cin>>pos[i];
    sort(pos+1,pos+1+m);
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i]>0){
            int dl;
            if(v0[i]>v)dl=d[i];
            else dl=d[i]+(v*v-v0[i]*v0[i])/(2*a[i]);
            int p;
            if(v0[i]>v)p=lower_bound(pos+1,pos+1+m,dl)-pos;
            else p=upper_bound(pos+1,pos+1+m,dl)-pos;
            if(p==m+1)continue;
            else{
                cnt++;
                l[cnt]=p;
                r[cnt]=m;
            }
        }
        if(a[i]==0){
            int p;
            if(v0[i]>v){
                p=lower_bound(pos+1,pos+1+m,d[i])-pos;
                if(p==m+1)continue;
                cnt++;
                l[cnt]=p;r[cnt]=m;
            }
            else continue;
        }
        if(a[i]<0){
            int flag=0;
            if(v0[i]<=v)continue;
            int dl=d[i]+(v0[i]*v0[i]-v*v-2*a[i]-1)/(-2*a[i]);
            int p1=lower_bound(pos+1,pos+1+m,d[i])-pos;
            if(p1==m+1)continue;
            int p2=lower_bound(pos+1,pos+1+m,dl)-pos;
            p2--;
            if(p1>p2)flag=1;
            if(flag==0){cnt++;
            l[cnt]=p1;r[cnt]=p2;}
        }
    }
    for(int i=1;i<=cnt;i++)pp[i]=make_pair(r[i],l[i]);
    sort(pp+1,pp+1+cnt);
    int cnt2=1;
    int rr=pp[1].first;
    for(int i=2;i<=cnt;i++){
        if(pp[i].second>rr){
            rr=pp[i].first;
            cnt2++;
        }
    }
    if(cnt==0)cnt2=0;
    cout<<cnt<<' '<<m-cnt2<<'\n';
}
int main(){
   freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)solve();
    return 0;
}
